﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EntityFrameworkETL.SaveBatchedChanges
{
    public interface IFakeReaderGenerator
    {
        DbDataReader GetReader(CommandCache command);
        long CurrentPrimaryKey();
    }

    public class FakeReaderGenerator : IFakeReaderGenerator
    {
        public FakeReaderGenerator()
        {}

        public long FakePKs { get; set; }

        public DbDataReader GetReader(CommandCache command)
        {
            var dataTable = new DataTable("FakeResults");
            dataTable.Columns.Add(new DataColumn("Id", typeof(Int32)));
            var dr = dataTable.NewRow();
            FakePKs -= 1;
            dr["Id"] = FakePKs;
            dataTable.Rows.Add(dr);
            return dataTable.CreateDataReader();
        }

        public long CurrentPrimaryKey()
        {
            return FakePKs;
        }
    }
}
